Machine Learning with R Cookbook by Unknown

Machine Learning with R Cookbook by Unknown

Author:Unknown
Language: eng
Format: mobi, epub
Publisher: Packt Publishing


How to do it...

Perform the following steps to train the neural network with nnet:

First, install and load the nnet package: > install.packages("nnet") > library(nnet)

Next, split the dataset into training and testing datasets: > data(iris) > set.seed(2) > ind = sample(2, nrow(iris), replace = TRUE, prob=c(0.7, 0.3)) > trainset = iris[ind == 1,] > testset = iris[ind == 2,]

Then, train the neural network with nnet: > iris.nn = nnet(Species ~ ., data = trainset, size = 2, rang = 0.1, decay = 5e-4, maxit = 200) # weights: 19 initial value 165.086674 iter 10 value 70.447976 iter 20 value 69.667465 iter 30 value 69.505739 iter 40 value 21.588943 iter 50 value 8.691760 iter 60 value 8.521214 iter 70 value 8.138961 iter 80 value 7.291365 iter 90 value 7.039209 iter 100 value 6.570987 iter 110 value 6.355346 iter 120 value 6.345511 iter 130 value 6.340208 iter 140 value 6.337271 iter 150 value 6.334285 iter 160 value 6.333792 iter 170 value 6.333578 iter 180 value 6.333498 final value 6.333471 converged



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.